package cn.edu.nankai.bookstore.controller.order;

import cn.edu.nankai.bookstore.domain.po.Order;
import com.fasterxml.jackson.databind.ObjectMapper;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "GetDealingOrderServlet", value = "/GetDealingOrderServlet")
public class GetDealingOrderServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession();
        ObjectMapper objectMapper = new ObjectMapper();
        String json = objectMapper.writeValueAsString((Order) session.getAttribute("order"));
        response.getWriter().write(json);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
